//http://ipic.staticsdo.com/external/sdo_beacon.js?129383532405
(function(l, w, h) {
    if (l.sdoLogger) {
        return
    }
    var B = {
		jsName:"sdo_beacon.js",
		defaultVer:20111215,
		getVersion:function() {
			var H = this.jsName;
			var D = new RegExp(H + "(\\?(.*))?$");
			var G = w.getElementsByTagName("script");
			for (var F = 0; F < G.length; F++) {
				var E = G[F];
				if (E.src && E.src.match(D)) {
					var C = E.src.match(D)[2];
					if (C && (/^[a-zA-Z0-9]+$/).test(C)) {
						return C
					}
				}
			}
			return this.defaultVer
		},
		getCookie:function(D) {
			var C = w.cookie.match(new RegExp("(^| )" + D + "=([^;]*)(;|$)"));
			return(C != null) ? unescape(C[2]) : "-"
		},
		setCookie:function(H, E, I, G, D, F) {
			var C = new Date;
			I = typeof I == "undefined" ? "" : ";expires=" + new Date(C.getTime() + (I * 24 * 60 * 60 * 1000)).toUTCString();
			w.cookie = H + "=" + E + I + ((D == null) ? "" : ("; domain=" + D)) + ((G == null) ? "" : ("; path=" + G)) + ((F == true) ? "; secure" : "")
		},
		parseError:function(D) {
			var E = "";
			for (var C in D) {
				E += C + "=" + D[C] + ";"
			}
			return E
		},
		getRand:function() {
			var E = new Date,
			C = function(J, K, H) {
				J = J.toString(36).split("");
				K = K / 4 | 0;
				H = H / 4 | 0;
				for (var I = K; I <= H; I++) {
					!J[I] && (J[I] = 0)
				}
				return J.slice(K, H + 1).join("")
			},
			D = function(H) {
				return Math.random() * (H + 1) | 0
			},
			G = function(J) {
				J = J.replace(/./g,function(M) {
						return M.charCodeAt()
					}).split("");
				var L = 16777619,K = 2166136261,H = J.length;
				for (var I = 0; I < H; I++) {
					K = (K ^ J[I]) * L
				}
				K += K << 13;
				K ^= K >> 7;
				K += K << 3;
				K ^= K >> 17;
				K += K << 5;
				K = K & 2147483647;
				K = K.toString(36);
				K.length < 6 && (K += (H % 36).toString(36));
				return K
			},
			F = [screen.width,screen.height,navigator.plugins.length,navigator.javaEnabled(),screen.colorDepth,location.href,navigator.userAgent].join("");
			return function() {
				var K = new Date,J = (+K + 631152000000).toString(36),H = C(D(4095), 0, 7) + C(D(8191), 0, 7) + C(D(8191), 0, 8),L = Math.random() * (251) + 50 | 0,I = [];
				J.length < 9 && (J += (K % 36).toString(36));
				for (; L--;) {
					I.push(Math.random())
				}
				return G(F) + G([w.documentElement.offsetWidth,w.documentElement.offsetHeight,history.length,new Date - E].join("")) + J + H + G(I.slice(0, 10).join("")) + G(I.slice(L - 9).join(""))
			}
		}(),
		getParam:function(G, F) {
			var C = null;
			if (G) {
				if (B.isString(G) || B.isNumber(G)) {
					C = G
				} else {
					if (B.isObject(G)) {
						var H = "";
						for (var E in G) {
							if (G[E] != null && G[E] != h) {
								var D = G[E];
								if (B.isArray(D)) {
									D = D.join(",")
								} else {
									if (B.isDate(D)) {
										D = D.getTime()
									}
								}
								H += E + "=" + D + "&"
							}
						}
						H = H.substring(0, H.length - 1);
						C = H
					} else {
						if (B.isArray(G)) {
							if (G.length & G.length > 0) {
								C = G.join(",")
							}
						} else {
							C = G.toString()
						}
					}
				}
			}
			if (!C) {
				C = "-"
			}
			if (F) {
				C = encodeURIComponent(C);
				C = this.base64encode(C)
			}
			return C
		},
		base64encode:function(J) {
			var D = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
			var F,H,C;
			var I,G,E;
			C = J.length;
			H = 0;
			F = "";
			while (H < C) {
				I = J.charCodeAt(H++) & 255;
				if (H == C) {
					F += D.charAt(I >> 2);
					F += D.charAt((I & 3) << 4);
					F += "==";
					break
				}
				G = J.charCodeAt(H++);
				if (H == C) {
					F += D.charAt(I >> 2);
					F += D.charAt(((I & 3) << 4) | ((G & 240) >> 4));
					F += D.charAt((G & 15) << 2);
					F += "=";
					break
				}
				E = J.charCodeAt(H++);
				F += D.charAt(I >> 2);
				F += D.charAt(((I & 3) << 4) | ((G & 240) >> 4));
				F += D.charAt(((G & 15) << 2) | ((E & 192) >> 6));
				F += D.charAt(E & 63)
			}
			return F
		},
		isString:function(C) {
			return(C != null) && (C != h) && (typeof C == "string") && (C.constructor == String)
		},
		isNumber:function(C) {
			return(typeof C == "number") && (C.constructor == Number)
		},
		isDate:function(C) {
			return C && (typeof C == "object") && C.constructor == Date
		},
		isArray:function(C) {
			return C && (typeof C == "object") && (C.constructor == Array)
		},
		isObject:function(C) {
			return C && (typeof C == "object") && (C.constructor == Object)
		},
		createFlash:function(C, E, F) {
			F = F && F.replace(/"/g, "&quot;");
			var D;
			E.id = E.id || "sdo_beacon_flash";
			if ("classid" in w.createElement("object")) {
				D = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" name="' + E.id + '" ' + (E.id ? 'id="' + E.id + '" ' : "") + 'width="' + E.width + '" height="' + E.height + '"><param name="allowScriptAccess" value="always" /><param name="quality" value="high" /><param name="wmode" value="window" /><param name="movie" value="' + E.src + '" />' + (F ? '<param name="flashvars" value="' + F + '" />' : "") + "</object>"
			} else {
				D = '<embed style="width:1px;height:1px;" wmode="window" src="' + E.src + '" quality="high" name="' + E.id + '" ' + (E.id ? 'id="' + E.id + '" ' : "") + (F ? 'flashVars="' + F + '" ' : "") + 'width="' + E.width + '" height="' + E.height + '"allowScriptAccess="always" type="application/x-shockwave-flash"/>'
			}
			C.innerHTML = D;
			return C.firstChild
		}
	}
	,i,n,s,p = false,q,r = 8000,f = "SNDA_SDO_BEACON_0"
	,g = "//ipic.staticsdo.com/external/share.swf",A = "//bf.snyu.sdo.com/bf?fn=sdoLogger.__FC__",k,m
	,z = function() {
        var D = navigator.plugins;
        if (D && D.length) {
            for (var C = D.length; C--;) {
                if (/Shockwave Flash/.test(D[C].name)) {
                    return D[C].description.substr(16)
                }
            }
        } else {
            if (l.ActiveXObject) {
                try {
                    return new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version").replace(/^WIN /i, "")
                } catch(E) {
                }
            }
        }
        return 0
    }()
	,j,v = function() {
        var C = [];
        return function(E) {
            var D = C.push(new Image) - 1;
            C[D].src = E
        }
    }()
	,y,d,x,b = function() {
        var C = x.pop();
        C && C();
        return !!C
    },u = function(E) {
        var C = E.length,G = 2048,F = Math.min(2083, G),D = 65536,H = Math.min(G, D);
        if (!+"\v1" || l.XDomainRequest) {
            return C <= F
        }
        return C <= H
    },a = isNaN(a = +B.getCookie("beacon_visit_count")) ? 1 : a + 1;
    B.setCookie("beacon_visit_count", a);
    var o = {
		uvId:"sdo_beacon_id",
		memId:"sdo_dw_track",
		beaconUrl:"dwtracking.sdo.com/a.gif",
		errorUrl:"dwtracking.sdo.com/dw/error.html",
		clickUrl:"dwtracking.sdo.com/ubs/click.html",
		pageId:typeof _beacon_pageid != "undefined" ? _beacon_pageid : B.getRand(),
		protocol:(w.URL.substring(0, w.URL.indexOf("://"))) + "://",
		tracking:function() {
			this.beaconLog()
		},
		beaconLog:function() {
			try {
				var I = this;
				j = "{" + B.getParam(this.getRefer()) + "}";
				var J = {};
				this.ptId = B.getCookie(this.memId);
				this.cId = B.getCookie(this.uvId);
				var H = this.ptId;
				var C = B.getCookie("b_t_s");
				var F = C == "-" || C.indexOf("s") == -1;
				if (H != "-") {
					J.memId = H
				}
				if (F) {
					J.subIsNew = 1;
					B.setCookie("b_t_s", C == "-" ? "s" : (C + "s"), 10000, "/")
				} else {
					J.subIsNew = 0
				}
				var L = "{" + B.getParam(J) + "}";
				var D = this.pageId;
				var K = w.title;
				if (K.length > 50) {
					K = K.substring(0, 49)
				}
				K = encodeURIComponent(K);
				var E = w.charset || w.characterSet;
				d = {pageId:D,title:K,charset:E,sr:l.screen.width + "*" + l.screen.height,vc:a,jv:+navigator.javaEnabled(),cd:l.screen.colorDepth,fv:z};
				typeof _beacon != "undefined" && B.isString(_beacon) && (d.cv = encodeURIComponent(_beacon));
				d.fc = k;
				x = [function() {
					delete d.charset
				},function() {
					delete d.sr
				},function() {
					delete d.vc
				},function() {
					delete d.cd
				},function() {
					delete d.jv
				},function() {
					delete d.fv
				},function() {
					delete d.title
				},function() {
					delete d.cv
				},function() {
					j = j.split("?")[0]
				},function() {
					var M = decodeURIComponent(d.title);
					d.title = encodeURIComponent(M.substr(0, 19))
				}];
				(y = function() {
					var M = "{" + B.getParam(d) + "}";
					var N = {r:j,a:L,b:M};
					I.sendRequest(I.beaconUrl, N)
				})()
			} catch(G) {
				this.sendError(G)
			}
		},
		getRefer:function() {
			var C = w.referrer;
			C == location.href && (C = "");
			try {
				C = "" == C ? opener.location : C;
				C = "" == C ? "-" : C
			} catch(D) {
				C = "-"
			}
			return C
		},
		clickLog:function(D) {
			try {
				var C = this.pageId;
				if (!C) {
					C = this.pageId = B.getRand()
				}
				var F = this.authId;
				if (!F) {
					F = "-"
				}
				if (B.isObject(D)) {
					D.pageId = C;
					D.authId = F
				} else {
					if (B.isString(D) && D.indexOf("=") > 0) {
						D += "&pageId=" + C + "&authId=" + F
					} else {
						if (B.isArray(D)) {
							D.push("pageId=" + C);
							D.push("authId=" + F);
							D = D.join("&")
						} else {
							D = {pageId:C,authId:F}
						}
					}
				}
				this.sendRequest(this.clickUrl, D)
			} catch(E) {
				this.sendError(E)
			}
		},
		sendError:function(E) {
			var D = B.parseError(E);
			var C = this.errorUrl + "?type=send&exception=" + encodeURIComponent(D.toString());
			var F = new Image();
			F.onload = function() {
				F = null
			};
			F.src = this.protocol + C
		},
		sendRequest:function(D, H) {
			var E = "";
			var G = new Date();
			try {
				if (H) {
					E = B.getParam(H, true);
					E = (E == "") ? E : (E + "&")
				}
				var C = "ver=" + B.getVersion() + "&time=" + G.getTime();
				D = this.protocol + D + "?" + E + C;
				if (!u(D)) {
					if (b()) {
						return y()
					}
				}
				v(D)
			} catch(F) {
				this.sendError(F)
			}
		}
	};
    if (location.protocol == "http:") {
        if (z) {
            (m = function() {
                var C = w.body;
                if (C) {
                    s = function() {
                        var F,E;
                        try {
                            F = n.get(f)
                        } catch(D) {
                            k = -1;
                            o.tracking();
                            return
                        }
                        if (F) {
                            k = F
                        } else {
                            k = "";
                            o.__FC__ = function(G) {
                                n.flush(f, G)
                            };
                            E = w.createElement("script");
                            C.insertBefore(E, C.firstChild);
                            E.src = A
                        }
                        o.tracking()
                    };
                    i = w.createElement("div");
                    C.insertBefore(i, C.firstChild);
                    i.style.cssText = "position:absolute;display:block;left:-500px;width:1px;height:1px;";
                    o.__FLASHREADY__ = function() {
                        if (p) {
                            return
                        }
                        p = true;
                        clearTimeout(q);
                        if (n.get && n.flush) {
                            s()
                        } else {
                            setTimeout(s, 100)
                        }
                    };
                    n = B.createFlash(i, {width:1,height:1,src:g});
                    q = setTimeout(function() {
                        if (p) {
                            return
                        }
                        if (n && n.get && n.flush) {
                            p = true;
                            s()
                        } else {
                            k = -1;
                            o.tracking()
                        }
                    }, r)
                } else {
                    setTimeout(m, 50)
                }
            })()
        } else {
            k = 0;
            o.tracking()
        }
    } else {
        k = -2;
        o.tracking()
    }
    l.sdoLogger = o;
    if (/\.ku6\.com$/.test(location.hostname)) {
        var t = 5;
        if (l.sdoLogger && l.sdoLogger.pageId && Math.round(Math.random() * 10) == t) {
            var c = B.getCookie("_expireYY");
            if (c == "-") {
                var e = "ms.yoyi.com.cn/r/m";
                e = l.sdoLogger.protocol + e + "?s=12&uid=" + l.sdoLogger.pageId;
                v(e);
                B.setCookie("_expireYY", 1, 30, "/")
            }
        }
    }
})(window, document);